package com.googlecode.cswish.model;

/**
 * 
 * @author feng Date: 2009-2-21
 */
public enum TextModel {
	TRUE("true"),
	FALSE("false"),
	@Deprecated
	TRUE_WITH_VALUE("both");
	
	private String textModel;
	
	private TextModel(String textModel) {
		this.textModel = textModel;
	}
	
	public static TextModel toTextModel(Object textModel) {
		if (textModel == null) {
			return FALSE;
		} else {
			if (textModel instanceof TextModel) {
				return (TextModel) textModel;
			} else {
				String sTextModel = textModel.toString();
				if (sTextModel.length() == 0 || "false".equals(sTextModel)) {
					return FALSE;
				} else if ("true".equals(sTextModel)) {
					return TRUE;
				} else {
					return TRUE_WITH_VALUE;
				}
			}
		}
	}
	
	public String toString() {
		return this.textModel;
	}
}